The present application relates generally to an improved data processing apparatus and method and more specifically to mechanisms for granting access to shared resources.
The Ricart-Agrawala algorithm is an algorithm for mutual exclusion on a distributed system. This algorithm was developed by Glenn Ricart and Ashok Agrawala, and is an extension and optimization of Lamport's Distributed Mutual Exclusion Algorithm which removes the need for release messages. With the Ricart-Agrawala algorithm, when a node (computing device) in a distributed environment needs to enter a critical section, i.e. a portion of code that accesses a shared resource (e.g., a data structure, device, or the like) that must not be concurrently accessed by other nodes, the node sends a notification to all the other nodes of which it is aware indicating the need to enter the critical section.
In response to receiving the notification, the receiving nodes, if not in the critical section, i.e. not accessing the shared resource, or is about to enter the critical section but has a lower priority value than the sender node, will approve the grant of access to the critical section by the sender node. If the receiving node is already in the critical section, i.e. accessing the shared resource, the receiving node will not approve the grant of access to the critical section by the sender node.
After the lapse of a wait time, the sender node determines if it has received response messages from all of the receiving nodes indicating approval of the grant of the access to the critical section. If so, the sender node will enter the critical section and access the shared resource. If the sender node does not get approval of the grant of access to the critical section, the sender node will again send out the notification and await responses, basically repeating the attempt to obtain access to the critical section.